﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS
{
    public partial class Articles : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                int catID = int.Parse(Request.QueryString["ID"].ToString());
                rptCatDatasource(catID);
                rptOtherCatDataSource(catID);
            }

        }

        protected void rptCatDatasource(int catID)
        {
            rptCat.DataSource = new cmsArticleBL().SelectByCategoryID(catID, 0);
            rptCat.DataBind();
        }

        protected void rptOtherCatDataSource(int catID)
        {
            rptOtherCat.DataSource = new cmsCategoryBL().SelectByParentID(catID, 10);
            rptOtherCat.DataBind();
        }

        public string Change_AV(string ip_str_change)
        {
            return Ultility.Change_AV(ip_str_change);
        }
        public string CheckDate(string sDate)
        {
            if (sDate != "")
            {
                //kiem tra ngay thang neu nho hon ngay hien tai (chu y parse sang datetime) 
                DateTime startDate = Convert.ToDateTime(sDate);
                DateTime now = DateTime.Now;
                TimeSpan elapsed = now.Subtract(startDate);
                double daysAgo = elapsed.TotalDays;
                if (daysAgo < 30)
                {
                    //return "<span class=\"red\">" + sDate; 
                    //return "<asp:Image ID=\"imgNew\" ImageUrl=\"~/images/New_icons_07.gif\" runat=\"server\" AlternateText=\"New\" />";
                    return "<img src=\"/images/New_icons_07.gif\" AlternateText=\"New\" />";
                }
                else
                {
                    return " ";
                }
            }
            else
                return "";
        }
    }
}
